package megrez.job.custom.web.vo;

import java.util.Date;

import org.springframework.beans.BeanUtils;

import lombok.Data;
import megrez.job.custom.domain.Config;

/**
 * 任务配置信息
 * 
 * @author Lucky Yang
 * @since 2.6.9
 */
@Data
public class ConfigVO {
    private String id;
    private Integer version;
    private String createdBy;
    private Date createdDate;
    private String lastModifiedBy;
    private Date lastModifiedDate;

    private String className;
    private String methodName;
    private String methodParams;
    private String cronExpression;
    private String remark;
    private Boolean enabled;

    public ConfigVO() {
    }

    public ConfigVO(String className, String methodName, String methodParams, String cronExpression, String remark,
            Boolean enabled) {
        this.className = className;
        this.methodName = methodName;
        this.methodParams = methodParams;
        this.cronExpression = cronExpression;
        this.remark = remark;
        this.enabled = enabled;
    }

    public static ConfigVO of(Config config) {
        if (config == null) {
            return null;
        }
        ConfigVO rslt = new ConfigVO();
        BeanUtils.copyProperties(config, rslt);
        return rslt;
    }

    public Config copyTo(Config config) {
        if (config == null) {
            return null;
        }
        BeanUtils.copyProperties(this, config, "id, logs");
        return config;
    }

    @Override
    public boolean equals(Object o) {
        return super.equals(o);
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }    
}
